package Interface.Relation;

import java.awt.Component;
import java.io.File;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import Interface.InterfaceErreur;

class MyCellRenderer extends JLabel implements ListCellRenderer {
     public  ImageIcon cleIcon = new ImageIcon(this.getClass().getResource("Image/cle1.jpg"));

     List<Boolean> listCle;
	private ImageIcon shortIcon  = new ImageIcon("");
     // This is the only method defined by ListCellRenderer.
     // We just reconfigure the JLabel each time we're called.

     public MyCellRenderer(List<Boolean> listCle) {
		this.listCle = listCle;

		
	}

	public Component getListCellRendererComponent(
       JList list,
       Object value,            // value to display
       int index,               // cell index
       boolean isSelected,      // is the cell selected
       boolean cellHasFocus)    // the list and the cell have the focus
     {
         String s = value.toString();
         setText(s);
       	 setIcon((this.listCle.get(index)) ? cleIcon : shortIcon);
       	 
   	   if (isSelected) {
   		   
             setBackground(list.getSelectionBackground());
	       setForeground(list.getSelectionForeground());
	   }
         else {
	       setBackground(list.getBackground());
	       setForeground(list.getForeground());
	   }
	   setEnabled(list.isEnabled());
	   setFont(list.getFont());
         setOpaque(true);
         return this;
     }
 }